package com.gui.base;

public class ValueTransDemo {

    public static void main(String[] args) {

        Person xiaoZhang = new Person("小张");
        Person xiaoLi = new Person("小李");
        swap(xiaoZhang, xiaoLi);
        System.out.println("main--" + xiaoZhang.getName());
        System.out.println("main--" + xiaoLi.getName());
    }


    private static void swap(Person person1, Person person2) {
        // person1 小张
        // person2 小李
        Person temp = person2;
        person2 = person1;
        person1 = temp;
        System.out.println(person1.getName());
        System.out.println(person2.getName());
    }


    static class Person {

        private String name;

        public Person(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    '}';
        }
    }
}



